package com.aurora.source.source.presenter;

import android.content.Context;

import com.aurora.source.base.BaseBean;
import com.aurora.source.base.BasePresenter;
import com.aurora.source.constant.AuroraConstants;
import com.aurora.source.source.bean.UserInfoBean;
import com.aurora.source.source.view.ILoginSourceView;
import com.aurora.source.util.netutil.SubscriberObserver;

import java.util.Map;

public class LoginSourcePresenter extends BasePresenter<ILoginSourceView> {

    public LoginSourcePresenter(ILoginSourceView baseView) {
        super(baseView);
    }

    public void loginSource(Map<String, String> params) {
        requestMethod.loginSource(params, new SubscriberObserver<BaseBean<UserInfoBean>>((Context) baseView,"正在登录中...") {
            @Override
            public void onSuccess(BaseBean<UserInfoBean> sourceDataBeanBaseBean) {
              //  Log.e("tag",sourceDataBeanBaseBean.getMsg());
                if (sourceDataBeanBaseBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)) {
                    baseView.onLoginSourceSuccess(sourceDataBeanBaseBean.getData());
                } else {
                    baseView.onLoginSourceFail(sourceDataBeanBaseBean.getMsg());
                }
            }

            @Override
            public void onError(String msg) {
          //      Log.e("tag",msg);
                baseView.onLoginSourceFail(msg);

            }

            @Override
            public void onFinish() {

            }
        });
    }
}
